# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>

pkgname=coccinelle
pkgver=1.1.1
pkgrel=1
pkgdesc="provides the spatch matching and transformation engine implementing semantic patch language"
url="https://coccinelle.gitlabpages.inria.fr/website/"
makedepends="
	autoconf
	automake
	ocaml
	ocaml-findlib
	ocaml-num
	ocaml-ocamldoc
	"
depends="
	pcre
	python3
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	"
# riscv64: ocaml
arch="all !riscv64"
license="GPL-2.0-only"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/coccinelle/coccinelle/archive/$pkgver.tar.gz

	unit-test-score.bin
	"

build() {
	./autogen
	./configure \
		--prefix=/usr \
		--enable-release=yes \
		--with-python=/usr/bin/python3

	# parallel build broken, but at least coccinelle is relatively small
	make -j 1
}

package() {
	make DESTDIR="$pkgdir" MANDIR="/usr/share/man" install
}

check() {
	# coccinelle runs unit tests and compares results with a score file to
	# track new regressions. We provide it as unit-test-score.bin new to the
	# APKBUILD.
	./spatch.opt \
		--testall \
		--no-update-score-file \
		--expected-score-file "$srcdir"/unit-test-score.bin
}

sha512sums="
f935aef406d3356a8e3d08fa7dacd6dd8d49aeb3f00668b775a63881b8d8a259acbbaa21348cb32a8a1cc5cf13dcf10d7e871de0f7c0abb6e45eac24e892df98  coccinelle-1.1.1.tar.gz
fbd6b52cbea7367f1dc103b9a1d6e7c0bb352952c6cc9436c484c1eb71d0fa605a67c51641be9dc3c72511f8efb78c2d937d4fae1986c3731905df2625c522d5  unit-test-score.bin
"
